﻿using Common.Achieve;
using Common;
using log4net;
using Microsoft.AspNetCore.Mvc.Filters;
using ModelDto;

namespace WebApplication1.Filter
{
    public class ExceptionFilterAttribute : Attribute, IExceptionFilter
    {
        private readonly Ilog4netHelper log;
        public ExceptionFilterAttribute(Ilog4netHelper log)
        {
            this.log = log;
        }
        public void OnException(ExceptionContext context)
        {
            var values = context.RouteData.Values;
            var controller = values["controller"];
            var action = values["action"];
            log.Error($"控制器：{controller},方法：{action},详细信息：{context.Exception}");
        }
    }
}
